import CryptoJS from 'crypto-js';

// 加密
export function aesEncrypt(text, secretKey) {
    const encrypted = CryptoJS.AES.encrypt(text, secretKey);
	console.log("encrypted-----",encrypted);
    return encrypted.toString();
}

// 解密
export function aesDecrypt(ciphertext, secretKey) {
	// {
 //        mode: CryptoJS.mode.CBC,
 //        padding: CryptoJS.pad.Pkcs7
 //    }
    const decrypted = CryptoJS.AES.decrypt(ciphertext, secretKey);
    return decrypted.toString(CryptoJS.enc.Utf8);
}

// const secretKey = 'mySecretKey123'; // 应该更复杂且安全
// const text = 'Hello, World!';

// const encryptedText = encrypt(text, secretKey);
// console.log('Encrypted:', encryptedText);

// const decryptedText = decrypt(encryptedText, secretKey);
// console.log('Decrypted:', decryptedText);